/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.crystalrange.files.service.impl;

import com.googlecode.genericdao.search.Search;
import com.googlecode.genericdao.search.SearchResult;
import java.util.Date;
import java.util.List;
import org.crystalrange.files.dao.FileTypeDao;
import org.crystalrange.files.model.FileType;
import org.crystalrange.files.service.FileTypeService;
import org.crystalrange.model.User;
import org.crystalrange.service.UserService;

/**
 *
 * @author Krzysiek
 */
public class FileTypeServiceImpl implements FileTypeService {
    
    private FileTypeDao fileTypeDao;
    private UserService userService;

    public FileTypeDao getFileTypeDao() {
        return fileTypeDao;
    }

    public void setFileTypeDao(FileTypeDao fileTypeDao) {
        this.fileTypeDao = fileTypeDao;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    
    public FileType create(String username) {
        User currentUser = this.userService.findByUsername(username);   
        
        FileType fileType = new FileType();
        fileType.setCreatedBy(currentUser);
        fileType.setCreatedDate(new Date());
        
        return fileType;
    }

    public boolean save(FileType fileType) {
        return this.fileTypeDao.save(fileType);
    }

    public boolean remove(FileType fileType) {
        return this.fileTypeDao.remove(fileType);
    }

    public FileType find(Long id) {
        return this.fileTypeDao.find(id);
    }

    public List<FileType> findAll() {
        return this.fileTypeDao.findAll();
    }

    public SearchResult<FileType> searchAndCount(Search search) {
        return this.fileTypeDao.searchAndCount(search);
    }

    public List<FileType> search(Search search) {
        return this.fileTypeDao.search(search);
    }

    public FileType searchUnique(Search search) {
        return this.fileTypeDao.searchUnique(search);
    }
    
}
